<template>
	<view class="news">
		<view class="newsItem" v-for="item in news">
			<image :src="item.show.img"></image>
			<view class="right">
				<view class="tit">
					{{item.title}}
				</view>
				<view class="info">
					<text>发表时间：{{showDate}}</text>
					<text>浏览：{{item.cfav}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				news: [],
				data: null
			}
		},
		computed: {
			showDate() {
				return `${this.data.getFullYear()}-${this.data.getMonth() +1}-${this.data.getDate()} ${this.data.getHours()}:${this.data.getMinutes()}`
			}
		},
		onLoad() {
			console.log()
			this.data = new Date()
			this.getNews()
		},
		methods: {
			async getNews() {
				const res = await this.$myRequest({
					url: '/home/data',
					data: {
						type: 'pop',
						page: this.page
					}
				})
				if (res) {
					this.news = res.data.data.list
				}
				console.log(res.data.data.list)
			}

		}
	}
</script>

<style lang="scss">
	.news {
		.newsItem {
			display: flex;
			padding: 10rpx 20rpx;
			border-bottom: 1px solid $shop;

			image {
				min-width: 200rpx;
				max-width: 200rpx;
				height: 150rpx;
			}

			.right {
				margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.tit {
					font-size: 33rpx;
				}

				.info {
					font-size: 24rpx;

					text:nth-child(2) {
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>
